﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Marbles.Core.Content.Assets;
using Marbles.Core.Content.CDN;

namespace Marbles.Web.Admin.Content
{
    public partial class Assets : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.ClientScript.IsClientScriptIncludeRegistered("marblesApplication")) { Page.ClientScript.RegisterClientScriptInclude("marblesApplication", Resources.ResourceHandler.GetApplicationJavascript(this)); }

            CDNParser cdn = new CDNParser();
            cdn.RegisterHeaderIncludes(this);
            
            string _type = "";
            if (!string.IsNullOrEmpty(Request.Params["type"])) { _type = Request.Params["type"].ToLower() + "/*"; }

            AssetCollection items = null;

            if (!string.IsNullOrEmpty(_type))
            {
                items = new AssetCollection(Core.Content.Sites.SiteDefinition.GetCurrent().SiteId, _type);
            }
            else
            {
                items = new AssetCollection(Core.Content.Sites.SiteDefinition.GetCurrent().SiteId);
            }

            cLstFiles.DataSource = items;
            cLstFiles.DataBind();
        }
    }
}